<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="传感器ids" prop="sensorIds">
        <el-input
            v-model="queryParams.sensorIds"
            placeholder="请输入传感器ids"
            clearable type="textarea"
            style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="排除传感器ids" prop="sensorIdsNotIn">
        <el-input
            v-model="queryParams.sensorIdsNotIn"
            placeholder="请输入排除传感器ids"
            clearable type="textarea"
            style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="开始时间" prop="beginTime">
        <el-input
            v-model="queryParams.beginTime"
            placeholder="请输入开始时间"
            clearable
            style="width: 200px"
        />
      </el-form-item>
      <el-form-item label="截止时间" prop="endTime">
        <el-input
            v-model="queryParams.endTime"
            placeholder="请输入截止时间"
            clearable
            style="width: 200px"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="doWithOutHisData">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            icon="Search"
            @click="getTokenValue"
        >查看Token</el-button>
      </el-col>
    </el-row>

  </div>

</template>

<script setup name="Nohisdata">
import {withOutHisData, getToken} from "@/api/dg/resend"
const { proxy } = getCurrentInstance();


const showSearch = ref(true);

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    sensorIds: undefined,
    sensorIdsNotIn: undefined,
    beginTime: undefined,
    endTime: undefined
  },
  rules: {
    // postName: [{ required: true, message: "岗位名称不能为空", trigger: "blur" }],
    beginTime: [{ required: true, message: "开始时间不能为空", trigger: "blur" }],
    endTime: [{ required: true, message: "截止时间不能为空", trigger: "blur" }],
  }
});

const { queryParams, form, rules } = toRefs(data);



/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  // getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  // handleQuery();
}

function doWithOutHisData(){
  let beginTime = !queryParams.value.beginTime?'':queryParams.value.beginTime,
      endTime = !queryParams.value.endTime?'':queryParams.value.endTime;
  if( queryParams.value.beginTime == '' || queryParams.value.endTime =='') {
    proxy.$modal.msgWarning("开始时间和截止时间必填 eg:2025-02-10 23:59:59");
    return;
  }
  let sensorIdStr = queryParams.value.sensorIds?queryParams.value.sensorIds:'';
  let sensorIds = []
  if (sensorIdStr !== '') {
    sensorIds = sensorIdStr.split(",")
  }
  let queryVo = {sensorIds, beginTime, endTime}

  withOutHisData(queryVo).then(response => {
    if (response.code === 200) {
      proxy.$modal.msgSuccess("修改成功");
      // open.value = false;
      // getList();
    }
  });

}

function getTokenValue(){
  getToken().then(resp => {
    if (resp.code === 200) {
      proxy.$modal.msgSuccess(resp.msg);
    } else {
      proxy.$modal.msgWarning(resp.msg);
    }
  })
}


</script>